package action;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMail {
	public static void main(String[] args) throws MessagingException {
		Properties properties = new Properties();
		properties.setProperty("mail.host", "smtp.163.com");
		properties.setProperty("mail.transport.protocol", "smtp");
		properties.setProperty("mail.smtp.auth", "true");
		
		Session session = Session.getDefaultInstance(properties);
		session.setDebug(true);
		Transport ts = session.getTransport();
		ts.connect("smtp.163.com", "qls880920@163.com", "KVCMMIQISRXVSLRX");
		MimeMessage message = new MimeMessage(session);
		message.setFrom(new InternetAddress("qls880920@163.com"));
		message.setRecipient(Message.RecipientType.TO, new InternetAddress("175816403@qq.com"));
		
		message.setSubject("只包含文本的简单邮件");
		
		message.setContent("你好", "text/html;charset=UTF-8");
		
		ts.sendMessage(message, message.getAllRecipients());
		ts.close();
	}

}
